/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package coms.json.action;

import coms.delegates.ConferenceDelegate;
import coms.delegates.ConferenceItemDelegate;
import coms.delegates.ConferenceRegistrationDelegate;
import coms.dto.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Pk
 */
public class ConferenceItemSelection extends coms.action.ComsActionSupport {

    private String itemval;
    private String confitem;
    private String conference;
    private List<ConferenceItem> conferenceItemList;
    private List<ConferenceRegistration> registeredConference;
    private List<Conference> bookedConference;

    public String getConfitem() {
        return confitem;
    }

    public void setConfitem(String confitem) {
        this.confitem = confitem;
    }

    public String getItemval() {
        return itemval;
    }

    public void setItemval(String itemval) {
        this.itemval = itemval;
    }

    public void setConference(String conference) {
        this.conference = conference;
    }

    public List<ConferenceItem> getConferenceItemList() {
        return conferenceItemList;
    }

    public void setConferenceItemList(List<ConferenceItem> conferenceItemList) {
        this.conferenceItemList = conferenceItemList;
    }

    public List<Conference> getBookedConference() {
        return bookedConference;
    }

    public void setBookedConference(List<Conference> bookedConference) {
        this.bookedConference = bookedConference;
    }

    public List<ConferenceRegistration> getRegisteredConference() {
        return registeredConference;
    }

    public void setRegisteredConference(List<ConferenceRegistration> registeredConference) {
        this.registeredConference = registeredConference;
    }

    public String getJSON() {
        return execute();
    }

    public String execute() {

        Map<String, Object> user = getSession();
        User u = (User) user.get("user");

        ConferenceRegistrationDelegate del = new ConferenceRegistrationDelegate();
        ConferenceRegistration reg = new ConferenceRegistration();
        
        reg.setParticipant(u);
        reg.setValid(true);
        
        registeredConference = del.search(reg);
        bookedConference = new ArrayList<Conference>();
        for (ConferenceRegistration r : registeredConference) {
            System.out.println(r.isValid());
            Conference c = r.getConference();
            bookedConference.add(c);
        }

        return SUCCESS;
    }
}
